<?php 
function http_post_json($url, $jsonStr)
{
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonStr);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
        'Content-Type: application/json; charset=utf-8',
        'Content-Length: ' . strlen($jsonStr)
    )
        );
    $response = curl_exec($ch);
    var_dump($response);
    $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    curl_close($ch);
    
    return array($httpCode, $response);
}
$access_token=getToken();
$url='https://api.weixin.qq.com/cgi-bin/express/business/order/add?access_token='.$access_token;

$openid='ohFb-40Zv6S5tbQpvCHzpjIfUrKo';
$order_id='test_012345678901_1';
 
/**
$receiver=array(
    "name"=>$Name,
    "tel"=>"",
    "mobile"=>$Mobile,
    "company"=>"",
    "post_code"=>"",
    "province"=>$Province,
    "country"=>"中国",
    "city"=>$City,
    "area"=>"",
    "address"=>str_replace("&"," ", $Address),
); 

$shop=array(
    "wxa_path"=>"pages/index/index", //前端给地址
    "img_url"=>'https://member.elixir.com.cn' . $goods_img,
    "goods_name"=>$goods_name_str,
    "goods_count"=>$goods_count,
);
$cargom=array(
    "count"=>$goods_count,
    "weight"=>1,
    "space_x"=>10,
    "space_y"=>10,
    "space_z"=>10,
    "detail_list"=>$detail_list,
);
*/
$orderInfo='{
  "add_source": 0,
  "order_id": "'.$order_id.'",
  "openid": "'.$openid.'",
  "delivery_id": "YUNDA",
  "biz_id": "2010225552",
  "custom_remark": "临时测试",
  "sender": {
    "name": "怡丽丝尔",
    "tel": "021-39291306",
    "mobile": "",
    "company": "ogilvy",
    "post_code": "200001",
    "country": "中国",
    "province": "上海市",
    "city": "上海市",
    "area": "青浦区",
    "address": "胜利路1588号"
  },
  "receiver": {
    "name": "宋先生",
    "tel": "",
    "mobile": "13681737112",
    "company": "",
    "post_code": "",
    "country": "中国",
    "province": "上海",
    "city": "上海",
    "area": "徐汇区",
    "address": "临时测试"
  },
  "shop": {
    "wxa_path": "/index/index?from=waybill&id=01234567890123456789",
    "img_url": "https://mmbiz.qpic.cn/mmbiz_png/OiaFLUqewuIDNQnTiaCInIG8ibdosYHhQHPbXJUrqYSNIcBL60vo4LIjlcoNG1QPkeH5GWWEB41Ny895CokeAah8A/640",
    "goods_name": "微信气泡狗抱枕&微信气泡狗钥匙扣",
    "goods_count": 2
  },
   "cargo": {
    "count": 2,
    "weight": 1,
    "space_x": 10,
    "space_y": 20,
    "space_z": 20,
    "detail_list": [{"name": "微信气泡狗抱枕","count": 1},{"name": "微信气泡狗钥匙扣2","count": 1}]
  },
  "insured": {
    "use_insured": 0,
    "insured_value": 0
  },
  "service": {
    "service_type": 0,
    "service_name": "标准快递"
  }
}';
$theorderInfo=json_decode($orderInfo, true);
$jsonInfo=json_encode($theorderInfo,  JSON_UNESCAPED_UNICODE);
 
echo $jsonInfo;
echo "<br /><br />"; 
$getdata=json_decode(http_post_json($url, $jsonInfo),true);
var_dump($getdata);